﻿@page "/blue-tooth"
@inject IStringLocalizer<Bluetooth> Localizer

<h3>@Localizer["BluetoothTitle"]</h3>

<PackageTips Name="BootstrapBlazor.Bluetooth" />

<Tips class="mt-2">
    <p>@((MarkupString)Localizer["Tips"].Value)</p>
</Tips>

<DemoBlock Title="@Localizer["BaseUsageTitle"]"
           Introduction="@Localizer["BaseUsageIntro"]"
           Name="Normal">
    @if (ShowUI)
    {
        <span>@Localizer["InnerUI"]</span>

        <Printer OnResult="OnResult" ShowUI="true" OnError="OnError" OnUpdateStatus="OnUpdateStatus" OnUpdateError="OnError" OnGetDevices="OnGetDevices" />

    }
    else
    {
        <p>@Localizer["BasicUsage"]</p>
        <Printer @ref="printer" OnResult="OnResult" OnError="OnError" OnUpdateStatus="OnUpdateStatus" OnUpdateError="OnError" OnGetDevices="OnGetDevices" />
        <div @ref="printer.PrinterElement">
            <button data-action="btnConnect" class="btn btn-outline-primary">@Localizer["ConnectButtonText"]</button>
            <button data-action="btnDisconnect" class="btn btn-outline-danger">@Localizer["DisconnectButtonText"]</button>
            <button data-action="tools" class="btn btn-outline-primary" @onclick="printer.Print">@Localizer["PrintButtonText"]</button>
        </div>
    }
    <hr />
<pre>@message</pre>
<pre style="color:green">@statusMessage</pre>
<pre style="color:red">@errorMessage</pre>
    <p />
    <button class="btn btn-link" @onclick="SwitchUI ">@Localizer["SwitchUI"]</button>
</DemoBlock>

<h4>@Localizer["BluetoothTitle"]</h4>

<DemoBlock Title="@Localizer["BluetoothBatteryLevelTitle"]"
           Introduction="@Localizer["BluetoothBatteryLevelIntro"]"
           Name="BatteryLevel">
    <button class="btn btn-outline-primary" @onclick="GetBatteryLevel ">@Localizer["GetBatteryLevelButtonText"]</button>
    <BatteryLevel @ref="batteryLevel" OnUpdateValue="OnUpdateValue" OnUpdateStatus="OnUpdateStatus" OnUpdateError="OnError" />
    <br />
    <progress max="100" value="@value"> @value % </progress>
    <pre>@message</pre>
    <pre style="color:green">@statusMessage</pre>
    <pre style="color:red">@errorMessage</pre>
</DemoBlock>

<h4>@Localizer["BluetoothHeartRate"]</h4>

<DemoBlock Title="@Localizer["BatteryLevelTitle"]"
           Introduction="@Localizer["BatteryLevelIntro"]"
           Name="HeartRate">
    <button class="btn btn-outline-primary" @onclick="GetHeartrate ">@Localizer["GetHeartrateButtonText"]</button>
    <button class="btn btn-outline-danger" @onclick="StopHeartrate ">@Localizer["StopHeartrateButtonText"]</button>
    <Heartrate @ref="heartrate" OnUpdateValue="OnUpdateValue" OnUpdateStatus="OnUpdateStatus" OnUpdateError="OnError" />
    <h3 style="color:red" data-action="heartrate"></h3>
    <pre>@message</pre>
    <pre style="color:green">@statusMessage</pre>
    <pre style="color:red">@errorMessage</pre>
</DemoBlock>

<AttributeTable Title="@Localizer["PrinterComponent"]" Items="@GetAttributes()" />

<AttributeTable Title="@Localizer["BatteryLevelComponent"]" Items="@GetAttributesBatteryLevel()" />

<AttributeTable Title="@Localizer["HeartrateComponent"]" Items="@GetAttributesHeartrate()" />

<AttributeTable Title="@Localizer["BluetoothDeviceClass"]" Items="@GetBluetoothDeviceAttributes()" />

<AttributeTable Title="@Localizer["PrinterOptionClass"]" Items="@GetPrinterOptionAttributes()" />
